package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MsgLog;
import com.ruoyi.system.service.IMsgLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 消息日志Controller
 *
 * @author ruoyi
 * @date 2024-04-01
 */
@RestController
@RequestMapping("/system/log")
public class MsgLogController extends BaseController
{
    @Autowired
    private IMsgLogService msgLogService;

    /**
     * 查询消息日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody MsgLog msgLog)
    {
        setStartPage(msgLog.getPageNum(),msgLog.getPageSize());
        List<MsgLog> list = msgLogService.selectMsgLogList(msgLog);
        return getDataTable(list);
    }

    /**
     * 获取消息日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(msgLogService.selectMsgLogById(id));
    }


    /**
     * 修改消息日志
     */
    @PreAuthorize("@ss.hasPermi('system:log:edit')")
    @Log(title = "消息日志", businessType = BusinessType.UPDATE)
    @PutMapping("/editStatus")
    public AjaxResult editStatus(@RequestBody MsgLog msgLog)
    {
        return toAjax(msgLogService.updateMsgLog(msgLog));
    }

    /**
     * 删除消息日志
     */
    @PreAuthorize("@ss.hasPermi('system:log:remove')")
    @Log(title = "消息日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable String id)
    {
        return toAjax(msgLogService.deleteMsgLogById(id));
    }
}
